package com.koo.modules.bja.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.koo.common.utils.MyStrUtil;
import com.koo.common.utils.PageUtils;
import com.koo.common.utils.Query;
import com.koo.modules.bja.dao.BjaUploadMemberDataDao;
import com.koo.modules.bja.entity.BjaUploadMemberDataEntity;
import com.koo.modules.bja.service.BjaUploadMemberDataService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.Map;

@Slf4j
@Service
public class BjaUploadMemberDataServiceImpl extends ServiceImpl<BjaUploadMemberDataDao, BjaUploadMemberDataEntity> implements BjaUploadMemberDataService {


    @Override
    public PageUtils queryPage(Map<String, Object> params) {

        Object key = params.get("key");
        LambdaQueryWrapper<BjaUploadMemberDataEntity> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.like(MyStrUtil.isNotEmpty(key), BjaUploadMemberDataEntity::getMemberId, key)
                .or().eq(MyStrUtil.isNotEmpty(key), BjaUploadMemberDataEntity::getMemberName, key);

        IPage<BjaUploadMemberDataEntity> page = this.page(
                new Query<BjaUploadMemberDataEntity>().getPage(params),
                queryWrapper
        );

        return new PageUtils(page);
    }

    @Override
    public Date selectMaxModifyDate() {
        return baseMapper.selectMaxModifyDate();
    }

}